/**
 * 
 */
package com.zhaoyan.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageInfo;
import com.zhaoyan.pojo.Company;
import com.zhaoyan.pojo.Plan;
import com.zhaoyan.pojo.PlanVo;
import com.zhaoyan.service.ComService;

/**
 * @author zhaoyan
 *
 * 2020年1月29日
 */

@Controller
public class ComController {
	
	@Autowired
	private ComService comService;

	/**
	 * 分页查询
	 * @param plan
	 * @param pageNum
	 * @param m
	 * @return
	 */
	@RequestMapping("findPlan")
	public String fnidPlan(PlanVo plan,@RequestParam(defaultValue = "1")Integer pageNum,Model m) {
		
		PageInfo<Plan> planPage = comService.findPlan(plan,pageNum);
		
		m.addAttribute("planPage", planPage);
		
		return "show";
	}
	
	/**
	 * 展示详情
	 * @param id
	 * @param m
	 * @return
	 */
	@RequestMapping("showDetail")
	public String findDetail(Integer id,Model m) {
		
		Plan plan = comService.showDetail(id);
		
		m.addAttribute("plan", plan);
		
		return "plan";
	}
	
	@RequestMapping("toAddPro")
	public String showPro() {
		
		return "add";
	}
	
	@RequestMapping("findComList")
	@ResponseBody
	public List<Company> findComList() {
		
		return comService.findComList();
	}
	
	
	@RequestMapping("addPlan")
	@ResponseBody
	public Integer addPlan(Plan plan) {
		
		return comService.addPlan(plan);
	}
}
